#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

void Operation(char t, int a, int b, int(*pa)[10], int n, int m)
{
    if (t == 'r')
    {
        for (int i = 0; i < m; i++)
        {
            int tmp = *(*(pa + a - 1) + i);
            *(*(pa + a - 1) + i) = *(*(pa + b - 1) + i);
            *(*(pa + b - 1) + i) = tmp;
        }
    }
    else if (t == 'c')
    {
        for (int i = 0; i < n; i++)
        {
            int tmp = *(*(pa + i) + a - 1);
            *(*(pa + i) + a - 1) = *(*(pa + i) + b - 1);
            *(*(pa + i) + b - 1) = tmp;
        }
    }
}

/*
2 2
1 2
3 4
1
r 1 2
*/
int main()
{
    int n = 0;
    int m = 0;
    int arr[10][10];
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            scanf("%d", &arr[i][j]);
        }
    }
    int k = 0;
    scanf("%d", &k);
    while (k > 0)
    {
        char t;
        int a;
        int b;
        getchar();
        scanf("%c %d %d", &t, &a, &b);
        Operation(t, a, b, arr, n, m);
        --k;
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            printf("%d ", arr[i][j]);
        }
        printf("\n");
    }
    return 0;
}
